import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

import '../widgets/Iconfonts.dart';
import 'FavoritePage.dart';
import 'HistoryPage.dart';
import 'HomePage.dart';
import 'MyPage.dart';

class ScaffoldPage extends StatelessWidget {
  final SystemUiOverlayStyle _style =
      SystemUiOverlayStyle(statusBarColor: Colors.transparent);

  @override
  Widget build(BuildContext context) {
    SystemChrome.setSystemUIOverlayStyle(_style);
    // TODO: implement build
    return MaterialApp(
      home: ScaffoldWidget(),
      theme: ThemeData(primarySwatch: Colors.yellow),
    );
  }
}

class ScaffoldWidget extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    // TODO: implement createState
    return _ScaffoldPage();
  }
}

class _ScaffoldPage extends State<StatefulWidget> {

  int pageIndex = 0;
  List<StatelessWidget> pageList = [HomePage(), FavoritePage(), HistoryPage(), MyPage()];

  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Scaffold(
      appBar: AppBar(
        leading: Icon(
          Icons.menu,
          color: Colors.white,
        ),
        title: Text("Scaffold Page"),
        centerTitle: true,
        actions: <Widget>[
          IconButton(
            icon: Icon(Iconfonts.oppo),
            onPressed: () {
              debugPrint("oppo onPressed()");
            },
          )
        ],
      ),
      body: pageList[pageIndex],
      bottomNavigationBar: BottomNavigationBar(
        items: <BottomNavigationBarItem>[
          BottomNavigationBarItem(
              title: Text(
                "Home",),
              icon: Icon(
                Iconfonts.xiaomi,
                color: Colors.grey,
              )),
          BottomNavigationBarItem(
              title: Text("Favorite",), icon: Icon(Iconfonts.huawei,color: Colors.grey,)),
          BottomNavigationBarItem(
              title: Text("History",), icon: Icon(Iconfonts.oppo,color: Colors.grey,)),
          BottomNavigationBarItem(
              title: Text("my",), icon: Icon(Iconfonts.vivo,color: Colors.grey,)),
        ],
        onTap: (value){
          setState(() {
            pageIndex = value;
          });
        },
      ),
      floatingActionButton: FloatingActionButton(
        child: Icon(Icons.add),
        onPressed: () {
          debugPrint("floatingActionButton clicked");
        },
      ),
    );
  }
}
